package com.tea.funct.service.impl;

import com.tea.common.utils.DateUtils;
import com.tea.funct.domain.TeaFocus;
import com.tea.funct.domain.TeaProduct;
import com.tea.funct.mapper.TeaProductMapper;
import com.tea.funct.service.ITeaProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 产品管理Service业务层处理
 *
 * @author Sophia
 * @date 2024-05-25
 */
@Service
public class TeaProductServiceImpl implements ITeaProductService {
    @Autowired
    private TeaProductMapper teaProductMapper;

    /**
     * 查询产品管理
     *
     * @param id 产品管理主键
     * @return 产品管理
     */
    @Override
    public TeaProduct selectTeaProductById(Long id) {
        return teaProductMapper.selectTeaProductById(id);
    }

    /**
     * 查询产品管理列表
     *
     * @param teaProduct 产品管理
     * @return 产品管理
     */
    @Override
    public List<TeaProduct> selectTeaProductList(TeaProduct teaProduct) {
        return teaProductMapper.selectTeaProductList(teaProduct);
    }

    /**
     * 新增产品管理
     *
     * @param teaProduct 产品管理
     * @return 结果
     */
    @Override
    public int insertTeaProduct(TeaProduct teaProduct) {
        teaProduct.setCreateTime(DateUtils.getNowDate());
        return teaProductMapper.insertTeaProduct(teaProduct);
    }

    /**
     * 修改产品管理
     *
     * @param teaProduct 产品管理
     * @return 结果
     */
    @Override
    public int updateTeaProduct(TeaProduct teaProduct) {
        teaProduct.setUpdateTime(DateUtils.getNowDate());
        return teaProductMapper.updateTeaProduct(teaProduct);
    }

    /**
     * 批量删除产品管理
     *
     * @param ids 需要删除的产品管理主键
     * @return 结果
     */
    @Override
    public int deleteTeaProductByIds(Long[] ids) {
        return teaProductMapper.deleteTeaProductByIds(ids);
    }

    /**
     * 删除产品管理信息
     *
     * @param id 产品管理主键
     * @return 结果
     */
    @Override
    public int deleteTeaProductById(Long id) {
        return teaProductMapper.deleteTeaProductById(id);
    }

    @Override
    public void insertTeaProductAll(List<TeaProduct> teaProducts) {
        teaProductMapper.insertTeaProductAll(teaProducts);
    }

    @Override
    public void updateProductSubclassId(Long subclass_id, String productId) {
        teaProductMapper.updateProductSubclassId(subclass_id, productId);
    }


    @Override
    public void updateProductSubclassIdAll(List<TeaProduct> teaProducts) {
        teaProductMapper.updateProductSubclassIdAll(teaProducts);
    }


    @Override
    public TeaProduct selectTeaProductByFlagId(String productId) {
        return teaProductMapper.selectTeaProductByFlagId(productId);
    }

    @Override
    public void updateTeaProductAll(List<TeaProduct> teaProducts) {
        teaProductMapper.updateTeaProductAll(teaProducts);
    }

    @Override
    public TeaFocus selectFocusByProductIdAndUserId(Long productId, Long userId) {
        return teaProductMapper.selectFocusByProductIdAndUserId(productId, userId);
    }

    @Override
    public Integer removeFocusByProductIdAndUserId(Long productId, Long userId) {
        return teaProductMapper.removeFocusByProductIdAndUserId(productId, userId);
    }

    @Override
    public Integer addTeaFocus(Long productId, Long userId) {
        return teaProductMapper.addTeaFocus(productId, userId);
    }

    @Override
    public Integer removeFocusByProductIdsAndUserId(List<Long> productIds, Long userId) {
        return teaProductMapper.removeFocusByProductIdsAndUserId(productIds, userId);
    }

    @Override
    public List<TeaProduct> selectProductByFocus(Long userId) {
        return teaProductMapper.selectProductByFocus(userId);
    }

    @Override
    public List<TeaProduct> selectTeaProductListByQuery(TeaProduct teaProduct) {
        return teaProductMapper.selectTeaProductListByQuery(teaProduct);
    }

    @Override
    public List<TeaProduct> selectListByNotImportFlag(List<Long> ids, Long userId) {
        return teaProductMapper.selectListByNotImportFlag(ids, userId);
    }

    @Override
    public List<TeaProduct> selectListByProductIdsAndUserId(List<Long> ids, Long userId) {
        return teaProductMapper.selectListByProductIdsAndUserId(ids, userId);
    }

    @Override
    public void updateTeaProductAllByFlagId(List<TeaProduct> teaProducts) {
        teaProductMapper.updateTeaProductAllByFlagId(teaProducts);
    }
}
